<!DOCTYPE html>
<html>
<head>
		<title>淘宝小赢家-查询产品</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
<script src="bootstrap/js/jquery.min.js"></script>
		<script src="bootstrap/js/bootstrap.js"></script>
<{include file='layouts/headNav.html'}>
<div class="container-fluid">
	<div class="row-fluid">
		<div class="span10">
			<!--Body content-->
			<ul class="nav nav-tabs">
				<li class="active"><a href="<{spUrl c=$_controller a=search}>">产品列表</a></li>
				<{if $spAcl == 'ADMIN'}>
				<li><a href="<{spUrl c=$_controller a=create}>">新增产品</a></li>
				<{/if}>
			</ul>
			<{if $_attributeFormset}>
			<form method="post" action="<{spUrl c=$_controller a=search}>">
				<table>
				<tr>
					<{foreach from=$_attributes key=key item=attribute}>
					<{if $_attributeFormset&& isset($_attributeFormset[$key]) && $_attributeFormset[$key]['type'] == 'textField'}>
					<td><{$attribute}>
					<{cbForm moreParams=$_attributeFormset[$key] name="`$_controller`[`$key`]"}>							
					<input type="hidden" name="<{$_controller}>_searchType[<{$key}>]" value="0"/>
					</td>
					<{/if}>
					<{/foreach}>
					<td>&nbsp;&nbsp;&nbsp;&nbsp;<button type="submit" class="btn btn-primary">开始查询</button></td>
					<!--<button type="reset" class="btn">清除重填</button>-->
				</tr>
				</table>
			</form>
			<{/if}>
			
			<table class="table table-striped table-bordered table-hover">
				<thead>
					<tr>
						<{foreach from=$_attributes item=attribute}>
						<th><{$attribute}></th>
						<{/foreach}>
						<{if $spAcl == 'ADMIN'}>
						<th width="150px">操作</th>
						<{/if}>
					</tr>
				</thead>
				<tbody>
				<{if !empty($tpl_datas)}>
				
					<{foreach from=$tpl_datas item=data}>
					<tr>
						<{foreach from=$_attributes key=key item=attribute}>
						<td>
							<{if $key == 'bigImg'}>
								<{if $data[$key]}>
									<img src="img/good_pic/<{$data[$key]}>" style="width:30px;height:20px;"/>
								<{else}>
									<img src="img/good_pic/no_pic.jpg"  style="width:30px;height:20px;"/>
								<{/if}>
							<{else}>
							<{if isset($_attributeFormset) && isset($_attributeFormset[$key]) && ($_attributeFormset[$key]['type']|strtolower == 'dropdownlist' || $_attributeFormset[$key]['type']|strtolower == 'radio')}>
							<{$_attributeFormset[$key]['options'][$data[$key]]}>
							<{else}>
							<{$data[$key]}>
							<{/if}>
							<{/if}>
						</td>
						<{/foreach}>
						<{if $spAcl == 'ADMIN'}>
						<td>
							<div class="">
								<div class="">
								
									<a class="" href="<{spUrl c=$_controller a=view id=$data[$_pk]}>">详细</a>
									<a class="" href="<{spUrl c=$_controller a=update id=$data[$_pk]}>">编辑</a>
									<a class=" deleteConfirm" href="<{spUrl c=$_controller a=delete id=$data[$_pk]}>">删除</a>
									
								</div>
							</div>
						</td>
						<{/if}>
					</tr>
					<{/foreach}>

					<{else}>
					<tr><td colspan=<{count($_attributes) + 1}>>暂无记录！</td></tr>
					<{/if}>
				</tbody>
			</table>
			
			<{if !empty($tpl_pager)}>
			<div class="rows">
				<div class="span6">
					<div class="pagination pagination-right">
						<ul>
							<li><a data="<{$tpl_pager['prev_page']}>" href="#">«</a></li>
							<{foreach from=$tpl_pager['all_pages'] item=page}>
							<{if $page > 10}>
								<{if $tpl_page > $page}>
								<li class="active"><a data="<{$tpl_page}>" href="#"><{$tpl_page}></a></li>
								<{/if}>
								<{if $tpl_page < $tpl_pager['last_page']}>
								<li><a data="<{$tpl_pager['last_page']}>" href="#"><{$tpl_pager['last_page']}></a></li>
								<{/if}>
								<{break}>
							<{/if}>
							<li <{if $page eq $tpl_page}>class="active"<{/if}>><a data="<{$page}>" href="#"><{$page}></a></li>
							<{/foreach}>
							<li><a data="<{$tpl_pager['next_page']}>" href="#">»</a></li>
						</ul>
					</div>
				</div>
				<div class="span6" style="height:75px; line-height: 68px;">
					<form method="post" action="<{spUrl c=$_controller a=search}>" class="form-search pageForm">
						<{if !empty($tpl_keyword)}>
						<{foreach from=$tpl_keyword key=key item=value}>
						<input name="<{$_controller}>[<{$key}>]" type="hidden" />
						<{/foreach}>
						<{/if}>
						<{if !empty($tpl_searchType)}>
						<{foreach from=$tpl_searchType key=key item=value}>
						<input name="<{$_controller}>_searchType[<{$key}>]" type="hidden" />
						<{/foreach}>
						<{/if}>
						<input name="page" type="text" class="input-mini search-query" value="<{$tpl_page}>">
						<button type="submit" class="btn">Go</button>
					</form>
				</div>
			</div>
			<{/if}>
			<{if !empty($tpl_keyword)}>
			<{foreach from=$tpl_keyword key=key item=value}>
			<script>jQuery('[name="<{$_controller}>[<{$key}>]"]').val('<{$value}>');</script>
			<{/foreach}>
			<{/if}>
			<{if !empty($tpl_searchType)}>
			<{foreach from=$tpl_searchType key=key item=value}>
			<script>jQuery('[name="<{$_controller}>_searchType[<{$key}>]"]').val('<{$value}>');</script>
			<{/foreach}>
			<{/if}>
		</div>
	</div>
</div>
<script>
	(function($){
		$('.deleteConfirm').click(function(){
			if(confirm('您确认删除该条记录吗？该操作不可逆。'))
				return true;
			else
				return false;
		})
		$('.pagination ul li').click(function(){
			$('.pageForm [name="page"]').val($(this).find('a').attr('data'));
			$('.pageForm').submit();
			return false;
		})
	})(jQuery)
</script>
</body>
</html>